// app.js
App({
  data: {
    url:'https://wxchat.ztkuaichong.com',
    // url:'https://192.168.0.88:3003',
    imageurl:'https://wxchat.ztkuaichong.com',
    appId:'wxcd7a0c1027942bdc',
    operatorId:'cdztcd',
    adviseList: [],
  }, 
  onLaunch() {
    //首页弹窗
    this.globalData.isShowAdvise = true
    let patch = wx.getStorageSync('isFirstViewPatch')
    console.log('是否存在第一次记录',patch)
    if(!patch){
      wx.setStorageSync('isFirstViewPatch', true)
    }else{
      this.globalData.isFirstViewPatch = false
    }
    this.getAdvise()
    console.log('确认初始化')
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    this.userlogin();

    //soket
  },
  userlogin: function(res) {
    let that = this
    console.log('执行登陆')
    //跳转到登录页
    // wx.navigateTo({
    //   url: 'subpage/pages/login/login',
    //   success: function () {
    //     console.log('跳转登陆')
    //   }
    // })
  },
  //验证登陆过期7天
  isexpire: function () {
    let that = this
  },
 // 广告
 getAdvise : function(){
  let that = this
   wx.request({
     url: this.data.url+'/index/activity/list',
     method: "GET",
     success: (res)=> {
       console.log('获取广告', res.data.list)
      //  this.globalData.adviseList = res.data.list
      if(res.data.list.length <= 0){
        res.data.list = ''
      }else{
        res.data.list =  JSON.stringify(res.data.list)
      }
       wx.setStorageSync('advise' ,res.data.list)
     }
   })
 },
  globalData: {
    userInfo: wx.getStorageSync('userinfo') ? JSON.parse( wx.getStorageSync('userinfo')) : {},
    token: wx.getStorageSync('token'),
    userPhone: wx.getStorageSync('userPhone'),
    utils: require("/utils/util"),
    isShowAdvise: false,
    serverPhone: '17381912715',
    isFirstViewPatch: true,
    // serviceReq: require("/utils/request")
  }
})
